package com.amor.app

import androidx.databinding.ViewDataBinding
import com.amor.net.ImageLoader
import com.hy.frame.mvvm.base.BaseViewModel
import com.hy.frame.ui.LoadingDialog
import com.hy.frame.util.ToastUtil



/**
 * title BaseFragment
 * author HeYan
 * date 2021/9/25
 * desc
 */
abstract class BaseFragment<DB : ViewDataBinding, VM : BaseViewModel> : com.hy.frame.mvvm.base.BaseFragment<DB, VM>() {

    protected val imgLoader by lazy { ImageLoader(this) }

    private var loadingDialog: LoadingDialog? = null

    override fun showLoading(msg: String?) {
        if (loadingDialog == null)
            loadingDialog = LoadingDialog(context)
        loadingDialog?.show(msg)
    }

    override fun dismissLoading() {
        loadingDialog?.dismiss()
    }

    override fun showToast(msg: String?) {
        ToastUtil.show(context, msg)
    }
}